﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Common;

namespace DataAccess
{
    interface IVariableFactory
    {
        BooleanVariable CreateBooleanVariable(Variable data);
        StringVariable CreateStringVariable(Variable data);
        IntegerVariable CreateIntegerVariable(Variable data);
    }

    class VariableFactory : IVariableFactory
    {
        public BooleanVariable CreateBooleanVariable(Variable data)
        {
            return new BooleanVariable(data.Name, data.Description, data.CurrentValue, data.Id);
        }

        public StringVariable CreateStringVariable(Variable data)
        {
            return new StringVariable(data.Name, data.Description, data.CurrentValue, data.Id);
        }

        public IntegerVariable CreateIntegerVariable(Variable data)
        {
            return new IntegerVariable(data.Name, data.Description, data.CurrentValue, data.Id);
        }
    }

    public class Client
    {
        public Variable ClientVariable(Variable variableData, string variableType)
        { 
            IVariableFactory factory = new VariableFactory();

            switch (variableType)
            {
                case "Boolean": return factory.CreateBooleanVariable(variableData); 
                case "Int32": return factory.CreateIntegerVariable(variableData); 
                case "String": return factory.CreateStringVariable(variableData); 

                default: 
                    throw new NotImplementedException();
                    return null;
            }
        }
    }
}
